package db.common;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

import javax.sql.DataSource;

import utils.PropertiesUtil;

public class DBHelper {
	private static DataSource ds;
	static {
		Properties prop = PropertiesUtil.getProperties(DBHelper.class
				.getResourceAsStream("date-source.properties"));

		String className = (String) prop.get("className");
		try {
			ds = (DataSource) Class.forName(className).newInstance();
		} catch (InstantiationException | IllegalAccessException
				| ClassNotFoundException e) {
			throw new RuntimeException(e);
		}

	}

	public static Connection getConnection() throws SQLException {
		return ds.getConnection();
	}
}
